package com.bocom.dao;

import java.util.Date;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.SessionFactory;

import com.bocom.entity.Sjbd;

//@Repository
public class SjbdDao {

	// @Autowired
	private SessionFactory sessionFactory;

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	@SuppressWarnings("unchecked")
	public List<Sjbd> findAll() {

		String hsql = "from t_sjbd";
		Query query = sessionFactory.getCurrentSession().createQuery(hsql);
		List<Sjbd> ulist = query.list();
		if (ulist.size() > 0) {
		}
		return ulist;
	}	
	
	@SuppressWarnings("unchecked")
	public List<Sjbd> select_kssj(Date kssj, Date jssj) {

		String hsql = "from t_sjbd  where kssj>=:kssj and kssj<=:jssj order by kssj";
		Query query = sessionFactory.getCurrentSession().createQuery(hsql);
//		query.setDate("kssj", kssj);
//		query.setDate("jssj", jssj);
		java.sql.Timestamp sql_kssj=new java.sql.Timestamp(kssj.getTime());
		java.sql.Timestamp sql_jssj=new java.sql.Timestamp(jssj.getTime());
		query.setTimestamp("kssj", sql_kssj);
		query.setTimestamp("jssj", sql_jssj);
//		System.out.println("SjbdDao hsql=" + hsql);
		List<Sjbd> ulist = query.list();
		if (ulist.size() > 0) {
		}
		return ulist;
	}

}
